#!/usr/bin/env python

import wx
import component

import __main as main

class Main(component.Interactor):
    '''Main class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:04 AM'''
    
    def install(self, view, presenter):
        super(Main, self).install(view, presenter)
        self.progress = main.Progress(view, presenter)
        self.contacts = main.Contacts(view, presenter)
        self.messages = main.Messages(view, presenter)
        self.message = main.Message(view, presenter)
        self.groups = main.Groups(view, presenter)
    
    def bind(self):
        super(Main, self).bind()
        
        view = self.view
        menu = view.MenuBar
        tool = view.ToolBar
        
        view.Bind(wx.EVT_MENU, self.close, menu.file.close)
        view.Bind(wx.EVT_MENU, self.showAbout, menu.help.about)
        
        view.Bind(wx.EVT_MENU, self.close, tool.close.tool)
        view.Bind(wx.EVT_MENU, self.showAbout, tool.about.tool)
        
        view.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.changePage, view.notebook)
    
    def close(self, event):
        self.presenter.close()
        event.Skip()
    
    def showAbout(self, event):
        self.presenter.showAbout()
        event.Skip()
    
    def changePage(self, event):
        self.presenter.changePage(event.OldSelection, event.Selection)
    
